/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sessionBeans;

import entities.Account;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author HOANG ANH
 */
@Stateless
public class AccountFacade extends AbstractFacade<Account> {
    @PersistenceContext(unitName = "National Level Paper PresentationPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public AccountFacade() {
        super(Account.class);
    }

    public Account findbyName(String username){
        Query q = em.createNamedQuery("Account.findByUsername");
                q = q.setParameter("username", username);
        List<Account> list = q.getResultList();
        return list.get(0);
    }

}
